<?php
/**
 * FastApp.
 * 9/19/24
 * @Author deepsea159
 * @Contact telegram:deepsea159
 */

namespace App\Game\Api\Controller;

namespace App\Game\Api\Controller;

use App\Fastapp\Api\Controller\ApiController;
use App\Fastapp\Aspect\ApiAuth;
use App\Game\Api\Service\FavoriteService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller('api/game/favorite'), ApiAuth]
class FavoriteController extends ApiController
{
    #[Inject]
    public FavoriteService $service;

    #[GetMapping('list')]
    public function list(): ResponseInterface
    {
        return $this->success($this->service->list($this->request->all()));
    }

    #[PostMapping('add')]
    public function add(): ResponseInterface
    {
        $this->service->add($this->request->input('game_id'), 0, null, $this->request->input('status'));
        return $this->success();
    }

    #[GetMapping('last')]
    public function last(): ResponseInterface
    {
        return $this->success($this->service->last());
    }
}